package com.eightbears.beboy.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eightbears.beboy.R;
import com.eightbears.beboy.base.util.CommonUtils;
import com.eightbears.beboy.entity.ShopSetMealEntity;

public class ShopSetMealEditAdapter extends BaseQuickAdapter<ShopSetMealEntity.SetMeal, BaseViewHolder> {

    public ShopSetMealEditAdapter() {
        super(R.layout.item_edit_set_meal, null);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ShopSetMealEntity.SetMeal setMeal) {
        String dateString = String.format(
                mContext.getResources().getString(R.string.text_valid_date),
                CommonUtils.TimeStamp2Date(setMeal.getStart_at(), "yyyy-MM-dd"),
                CommonUtils.TimeStamp2Date(setMeal.getEnd_at(), "yyyy-MM-dd"));
        String disPrice = String.format(mContext.getString(R.string.text_price), setMeal.getDiscount_price());
        String price = String.format(mContext.getString(R.string.text_price), setMeal.getPrice());
        CommonUtils.loadImageView(mContext, setMeal.getCover(),
                R.mipmap.icon_default_shop, ((ImageView) baseViewHolder.getView(R.id.iv_shop)));
        baseViewHolder.setText(R.id.tv_shop_name, setMeal.getTitle())
            .setText(R.id.tv_valid_time, dateString)
            .setText(R.id.tv_dis_price, disPrice)
            .setText(R.id.tv_price, price)
            .addOnClickListener(R.id.ll_edit)
            .addOnClickListener(R.id.ll_delete);
    }

}

